package com.example.birdfriends.utils.wordSplice;

import org.springframework.stereotype.Service;
import org.wltea.analyzer.core.IKSegmenter;
import org.wltea.analyzer.core.Lexeme;

import java.io.IOException;
import java.io.StringReader;
import java.util.ArrayList;
import java.util.List;

@Service
public class CutWord {
    // 分词类
    public List<String> cutSentence(String msg) throws IOException {
        StringReader sr = new StringReader(msg);
        IKSegmenter ik = new IKSegmenter(sr, true);
        Lexeme lexeme = null;
        List<String> list = new ArrayList<>();
        while ((lexeme = ik.next()) != null){
            list.add(lexeme.getLexemeText());
        }

        return list;
    }
}
